#pragma once
#include <iostream>
#include <functional>
#include <string>
#include <thread>
#include <queue>
#include <mutex>

enum LgLevel
{
	LL_None = 0x00,
	LL_Test = 0x01,
	LL_Error = 0x02,
	LL_Warn = 0x04,
	LL_Info = 0x08,
	LL_Dbg = 0x10,
	LL_All = LL_Test|LL_Error| LL_Warn| LL_Info| LL_Dbg,
};

void DPA(LgLevel lev,const char* fmt, ...);

void DPW(LgLevel lev, const wchar_t* fmt, ...);

using CallbackLogInfo = std::function<void(std::wstring logInfo)>;

class LogInfoChinese
{
public:
	static void append(LgLevel lv,std::wstring info);
	static CallbackLogInfo OnAppend;
};

class PrintDebugView
{
public:
	
	//static PrintDebugView single;
	void PushString(std::string line);
	void PushWString(std::wstring line);
	~PrintDebugView()
	{
		mIsRunning = false;
		if (mThread.joinable())
			mThread.join();
	}

private:
	PrintDebugView()
	{
		mIsRunning = true;
		mThread = std::thread(&PrintDebugView::thread_func,this);
	}

	void thread_func();

private:
	std::thread mThread;
	std::mutex mLockQueStr;
	std::mutex mLockQueWStr;
	std::queue<std::string> mQueueStr;
	std::queue<std::wstring> mQueueWStr;
	bool mIsRunning = false;
};